home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / 93src.lha / src / cps / cmachine.sig < prev    next >
Encoding:
Text File  |  1993-01-27  |  6.1 KB  |  158 lines

  1. (* cmachine.sig
  2.  *
  3.  * COPYRIGHT (c) 1991 by AT&T Bell Laboratories
  4.  *)
  5.  
  6. signature CMACHINE =
  7.   sig
  8.  
  9.   (* effective addresses.  It is assumed that the following kinds exist:
  10.    *   register;
  11.    *   immediate label:  
  12.    *      This mode doesn't in fact exist on the Vax or the MC68020,
  13.    *      but it can be simulated (e.g. by "move address" instructions).
  14.    *   immediate integer literal;
  15.    *)
  16.     type EA
  17.  
  18.     val immed : int -> EA        (* makes the immediate integer mode *)
  19.  
  20.   (* DEDICATED REGISTERS *)
  21.   (* The following registers can hold pointers or properly tagged integers *)
  22.     val exnptr : EA            (* the current exception-handler *)
  23.  
  24.   (* The following may be a register (indexable or not) or a memory location. *)
  25.     val varptr: EA            (* the var array *)
  26.     val varptr_indexable : bool (* true iff varptr is an indexable register *)
  27.  
  28.   (* The following register may not hold pointers, and may hold untagged ints *)
  29.     val arithtemps : EA list
  30.       (* If arithtemps are present, then every attempt must be made to do 
  31.        * "arithmetic" operations in arithtemp and arithtemp2 rather than
  32.        * general registers.  This is all for the 68020.  Note that arithtemps
  33.        * on that machine are not capable of all the operations
  34.        * that "general" registers can do, and vice versa.  
  35.        *)
  36.  
  37.   (* The following registers are not dedicated, and must be all disjoint *)
  38.     val standardlink : EA
  39.     val standardclosure : EA
  40.     val standardarg : EA
  41.     val standardcont : EA
  42.     val miscregs : EA list
  43.     val floatregs : EA list
  44.     val savedfpregs : EA list
  45.  
  46.     val move : EA * EA -> unit  (* move(a,b)    a -> b *)
  47.  
  48.     val align : unit -> unit  (* ensure that next code is on 4-byte boundary *)
  49.     val mark: unit -> unit    (* insert a gc-tag in the code so that next address
  50.                    * may be moved into a record *)
  51.     val emitlong : int -> unit (* put an 4-byte integer literal into the code *)
  52.     exception BadReal of string
  53.     val realconst : string -> unit  (* put a floating literal into the code *)
  54.     val emitstring : string -> unit (* put a literal string into the code
  55.                    (just the chars, no descriptor or length) *)
  56.     val emitlab : int * EA -> unit  (* L3: emitlab(k,L2) is equivalent to
  57.                    L3: emitlong(k+L2-L3) *)
  58.  
  59.     val newlabel : unit -> EA    (* create a new label (but don't define it) *)
  60.     val define : EA -> unit  (* Associate a label with a point in the code *)
  61.  
  62.   (* checkLimit (n,lab,mask):
  63.    * Generate code to check the heap limit to see if there is enough free space
  64.    * to allocate n bytes.  "mask" shows what miscregs are live.
  65.     "lab" is a label or register holding the resumption point.
  66.    *)
  67.     val testLimit: unit -> unit
  68.     val checkLimit : int * EA * EA -> unit
  69.  
  70.     val beginStdFn : EA * EA -> unit;  
  71.           (* Note the beginning of a standard function; useful for machines
  72.          that don't have PC-relative instructions and have
  73.                  to reset a base register.  First argument is a label,
  74.              second is a register pointing to that label. *)
  75.  
  76.     val jmp : EA -> unit      (* unconditional jump to the address specified *)
  77.  
  78.     val record : (EA * CPS.accesspath) list * EA -> unit
  79.          (* makes a new record, puts address of it
  80.             into the destination specified by the second arg.
  81.             The contents are numbered from ~1 and up. *)
  82.  
  83.   (* recordStore(x, y, alwaysBoxed) records a store operation into mem[x+2*(z-1)].
  84.    * The flag alwaysBoxed is true if the value stored is guaranteed to be boxed.
  85.    *)
  86.     val recordStore : (EA * EA * bool) -> unit
  87.  
  88.     val select : int * EA * EA -> unit  (* select(i,x,y) = y <- mem[x+4*i] *)
  89.     val offset : int * EA * EA -> unit  (* offset(i,x,y) = y <- x+4*i *)
  90.  
  91.   (* fetchindexb(x,y,z) fetches a byte: y <- mem[x+z], where y is not x or z *)
  92.     val fetchindexb : EA * EA * EA -> unit
  93.   (* storeindexb(x,y,z) stores a byte: mem[y+z] <- x. *)
  94.     val storeindexb : EA * EA * EA -> unit
  95.  
  96.     val jmpindexb : EA*EA -> unit        (* jmpindexb(x,y)    pc <- (x+y) *)
  97.  
  98.   (* fetchindexl(x,y,z) fetches a word: y <- mem[x+2*(z-1)] *)
  99.     val fetchindexl : EA * EA * EA -> unit   
  100.   (* storeindexl(x,y,z) stores a word: mem[y+2*(z-1)] <- x *)
  101.     val storeindexl : EA * EA * EA -> unit   
  102.                             
  103.   (* fetchindexd(x,y,z): y<-mem[x+4*(z-1)] *)
  104.     val fetchindexd : EA * EA * EA -> unit 
  105.   (* storeindexd(x,y,z): mem[y+4*(z-1)]<-x *)
  106.     val storeindexd : EA * EA * EA -> unit 
  107.  
  108.     val ashl : EA * EA * EA -> unit  (* shift left: count, src, dest;
  109.                      shift count is non-negative *)
  110.     val ashr : EA * EA * EA -> unit  (* shift right: count, src, dest;
  111.                      shift count is non-negative *)
  112.        
  113.     val orb :  EA * EA * EA -> unit  (* bitwise or *)
  114.     val andb :  EA * EA * EA -> unit  (* bitwise and *)
  115.     val xorb :  EA * EA * EA -> unit  (* bitwise xor *)
  116.     val notb :  EA * EA -> unit  (* bitwise complement *)
  117.  
  118.     val add : EA * EA * EA -> unit  (* add(a,b,c):   c <- b+a *)
  119.     val sub : EA * EA * EA -> unit    (* sub(a,b,c):  c <- (b - a) *)
  120.  
  121.  
  122.   (* integer arithmetic with overflow trapping *)
  123.     val addt : EA * EA * EA -> unit
  124.     val subt : EA * EA * EA -> unit    (* subt(a,b,c):  c <- (b - a) *)
  125.     val mult : EA * EA -> unit
  126.     val divt : EA * EA -> unit        (* divt(a,b):  b <- (b div a) *)
  127.  
  128.     val bbs      : EA * EA * EA -> unit
  129.  
  130.     datatype condition = NEQ | EQL | LEQ | GEQ | LSS | GTR
  131.  
  132.   (* ibranch (cond, a, b, lab):  pc <- lab if (a <cond> b). *)
  133.     val ibranch : condition * EA * EA * EA -> unit
  134.  
  135.   (* rangeChk (a, b, lab):  pc <- lab if ((a < 0) or (b <= a)) *)
  136.     val rangeChk : EA * EA * EA -> unit
  137.  
  138.   (* double precision floating point arithmetic.  These take FP registers
  139.    * as their arguments.
  140.    *)
  141.     val fmuld : EA * EA * EA -> unit
  142.     val fdivd : EA * EA * EA -> unit
  143.     val faddd : EA * EA * EA -> unit
  144.     val fsubd : EA * EA * EA -> unit
  145.     val fnegd : EA * EA -> unit
  146.     val fabsd : EA * EA -> unit
  147.   (* convert an int to a double *)
  148.     val cvti2d : EA * EA -> unit    (* ea1=gpr, ea2=fpr *)
  149.   (* double test and branch *)
  150.     val fbranchd : condition * EA * EA * EA -> unit
  151.   (* load/store double precision floating point registers *)
  152.     val storefloat : EA * EA -> unit    (* ea1=fpr, ea2=gpr *)
  153.     val loadfloat: EA * EA -> unit    (* ea1=gpr, ea2=fpr *)
  154.  
  155.     val comment : string -> unit
  156.  
  157.   end (* CMACHINE *)
  158.